<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>N3RD CH4T: /Users/plamontagna/Documents/spa-cs340project/ChatServer/server.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">N3RD CH4T
   &#160;<span id="projectnumber">Final Version</span>
   </div>
   <div id="projectbrief">CS340 Project</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">/Users/plamontagna/Documents/spa-cs340project/ChatServer/server.h</div>  </div>
</div>
<div class="contents">
<a href="server_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00018"></a>00018 <span class="comment"></span><span class="comment">// ----------------------------------------------------------------------------</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef SERVER_H</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define SERVER_H</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;QDataStream&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;QDebug&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;QHash&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;QStringList&gt;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;QTcpServer&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;QTcpSocket&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;QTime&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;<a class="code" href="clientinformation_8h.html" title="Header file for clientInformation.cpp.">clientinformation.h</a>&quot;</span>
<a name="l00031"></a>00031 
<a name="l00040"></a><a class="code" href="class_server.html">00040</a> <span class="keyword">class </span><a class="code" href="class_server.html" title="Server helper methods.">Server</a> : <span class="keyword">public</span> QTcpServer
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042         Q_OBJECT
<a name="l00043"></a>00043     <span class="keyword">public</span>:
<a name="l00044"></a>00044 
<a name="l00046"></a>00046         <a class="code" href="class_server.html#a1950ac036d86af898428d7ba39bbf048" title="Server Constructor.">Server</a>(QObject *parent = 0);
<a name="l00047"></a>00047 
<a name="l00055"></a>00055         <span class="keywordtype">bool</span> <a class="code" href="class_server.html#a4d28bcf39a54fac77bbd48872035e2c6" title="Starts the server with the parameters passed in. Returns bool if successful or not.">startServer</a>(QHostAddress addr, quint16 port);
<a name="l00056"></a>00056 
<a name="l00057"></a>00057     <span class="keyword">protected</span>:
<a name="l00058"></a>00058 
<a name="l00065"></a>00065         <span class="keywordtype">void</span> <a class="code" href="class_server.html#afeda4b86ff6555c7a5bb012d2f464d19" title="Implements incomingConnection(handle) method in QTcpServer to handle any incoming connections...">incomingConnection</a>(<span class="keywordtype">int</span> handle);
<a name="l00066"></a>00066 
<a name="l00067"></a>00067     <span class="keyword">public</span> slots:
<a name="l00072"></a>00072         <span class="keywordtype">void</span> <a class="code" href="class_server.html#ab29aa2a33dd2662e95c5485b9bcec694" title="Slot that gets called whenever there is incoming data from any socket to the server.">handleIncomingData</a>();
<a name="l00073"></a>00073 
<a name="l00078"></a>00078         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a782b2d9f22711ac0cca57e990dfb83d0" title="Slot that gets called whenever a client disconnects from the server.">handleDisconnection</a>();
<a name="l00079"></a>00079 
<a name="l00080"></a>00080     signals:
<a name="l00087"></a>00087         <span class="keywordtype">void</span> <a class="code" href="class_server.html#afd11d6dc30d6fdf3ad5b30feb0c5c4ff" title="Signal sent to remove friend.">removeFriend</a>(<a class="code" href="classclient_information.html" title="Client helper methods.">clientInformation</a>* personSendingRequest, <span class="keywordtype">bool</span> isValidRequest);
<a name="l00088"></a>00088 
<a name="l00095"></a>00095         <span class="keywordtype">void</span> <a class="code" href="class_server.html#aa15d49a10e81b6c5f523f02663cdfb9d" title="Signal to check if the remove request was valid.">sendIsValidRemoveFriendRequest</a>(QString personToRemove, <span class="keywordtype">bool</span> isValidRequest);
<a name="l00096"></a>00096 
<a name="l00102"></a>00102         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a4632a3440adaece614f553e84fcc67ef" title="Signal sent to add a friend.">addFriend</a>(QString personSendingRequest);
<a name="l00103"></a>00103 
<a name="l00110"></a>00110         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a90fbc824ea7de283a02a268b510fd6f2" title="Signal sent to check if the friend request was valid or not.">sendIsValidFriendRequest</a>(QString personToAdd, <span class="keywordtype">bool</span> isValid);
<a name="l00111"></a>00111 
<a name="l00118"></a>00118         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a21329e064df7799d50e7d54a4b77f1d9" title="Signal sent to confirm friend request.">confirmFriendRequest</a>(<a class="code" href="classclient_information.html" title="Client helper methods.">clientInformation</a>* sentUser, <span class="keywordtype">bool</span> isAccepted);
<a name="l00119"></a>00119 
<a name="l00128"></a>00128         <span class="keywordtype">void</span> <a class="code" href="class_server.html#ac46199c15eb4e607a039567c5cce900e" title="Signal to send message.">sendMessage</a>(QString fromUser, QString toUser, QString message, QString timeSentAt);
<a name="l00129"></a>00129 
<a name="l00130"></a>00130     <span class="keyword">private</span>:
<a name="l00135"></a>00135         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a6851a20573fcaed7ffc102da9521be61" title="Method to check if the username sent was valid or not...deciding on whether or not to use...">handleIsValidUserName</a>(QTcpSocket* personThatSentData, QString nameOfUser, <span class="keywordtype">bool</span> isValidUsername);
<a name="l00136"></a>00136 
<a name="l00141"></a>00141         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a7261fe162d0d8492ca633965437ba00c" title="Method to handle an incoming friend add request, Parameters are self-explanatory.">handleIncomingFriendRequest</a>(QString personSendingRequest, QString personRecievingRequest, <span class="keywordtype">bool</span> isValid);
<a name="l00142"></a>00142 
<a name="l00147"></a>00147         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a0b5693825a399b5cf40e4e340e8b5b6b" title="Method to handle an incoming friend remove request, Parameters are self-explanatory.">handleIncomingRemoveFriendRequest</a>(QString personSendingRequest, QString personToRemove);
<a name="l00148"></a>00148 
<a name="l00154"></a>00154         <span class="keywordtype">void</span> <a class="code" href="class_server.html#a4271c40116b94faaf57a6e75fa545f37" title="Iterates over the users connected and sends out the updated users connected Called whenever someone c...">updateUsers</a>();
<a name="l00155"></a>00155 
<a name="l00161"></a>00161         <span class="keywordtype">void</span> <a class="code" href="class_server.html#ad9a4fa699bda4ce299b919229fea6314" title="Called when a user logs in and there are any requests to satisfy.">satisfyAnyRequests</a>(<a class="code" href="classclient_information.html" title="Client helper methods.">clientInformation</a>* user);
<a name="l00162"></a>00162 
<a name="l00167"></a><a class="code" href="class_server.html#abe5cd00d6bdf190b8fd14b8cba47a0ce">00167</a>         QHash&lt;QTcpSocket* , QString&gt; <a class="code" href="class_server.html#abe5cd00d6bdf190b8fd14b8cba47a0ce" title="Hashtable that contains the socket as the key and the username that&#39;s linked to the socket as the val...">userSocketStringTable</a>;
<a name="l00168"></a>00168 
<a name="l00173"></a><a class="code" href="class_server.html#a2ee26c91a91b2cc48f4ea7d5b2463a7b">00173</a>         QHash&lt;QString, clientInformation*&gt; <a class="code" href="class_server.html#a2ee26c91a91b2cc48f4ea7d5b2463a7b" title="Hashtable that contains the username as the key and the socket as the value.">userStringClientInformationTable</a>;
<a name="l00174"></a>00174 
<a name="l00179"></a><a class="code" href="class_server.html#a145ea61cfa694dee1fedef67f18c1f32">00179</a>         QHash&lt;QString, clientInformation*&gt; <a class="code" href="class_server.html#a145ea61cfa694dee1fedef67f18c1f32" title="Table to store the friends lists of all the users that at one point have connected.">overallUsers</a>;
<a name="l00180"></a>00180 
<a name="l00185"></a><a class="code" href="class_server.html#a77dfd551fe8d6d98b469a3181f11800f">00185</a>         QHash&lt;clientInformation*, clientInformation*&gt; <a class="code" href="class_server.html#a77dfd551fe8d6d98b469a3181f11800f" title="Stores the requests from and to the friend requests.">currentFriendRequests</a>;
<a name="l00186"></a>00186 
<a name="l00187"></a>00187 };
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 <span class="preprocessor">#endif // SERVER_H</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Tue Nov 29 2011 23:53:09 for N3RD CH4T by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
